package cn.tedu._04mvcboot01.controller;

import cn.tedu._04mvcboot01.pojo.UserLoginDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class UserController {
    //接收参数第1种方式:通过 HttpServletRequest request 接收
    /*
    @RequestMapping("/v1/users/login")
    @ResponseBody
    public String login(HttpServletRequest request){
        String username = request.getParameter("username");
        String password = request.getParameter("password");

        return username + ":" + password;
    }

     */

    //接收参数第2种方式:通过声明参数方式
    /*
    @RequestMapping("/v1/users/login")
    @ResponseBody
    public String login(String username, String password){
        return username + ":" + password;
    }

     */

    //接收参数第3种方式:声明POJO类[DTO类]
    /*
        1.实体类Entity
        2.VO类:服务端返回给客户端的数据
        3.DTO类:客户端发送给服务端的数据[此处需要使用]
     */
    @RequestMapping("/v1/users/login")
    @ResponseBody
    public String login(UserLoginDTO userLoginDTO){
        String username = userLoginDTO.getUsername();
        String password = userLoginDTO.getPassword();

        return username + ":" + password;
    }
}








